home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000096_icon-group-sender _Fri Apr 22 16:12:00 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  3KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 22 Apr 1994 18:01:20 MST
  2. Date: Fri, 22 Apr 1994 16:12:00 -0600 (CST)
  3. From: Chris Tenaglia - 257-8765 <TENAGLIA@MIS.MCW.EDU>
  4. Subject: ff.icn
  5. To: icon-group@cs.arizona.edu
  6. Message-Id: <01HBHB4TC70Y8WYD3G@mis.mcw.edu>
  7. Organization: Medical College of Wisconsin (Milwaukee, WI)
  8. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  11. Content-Transfer-Encoding: 7BIT
  12. Status: R
  13. Errors-To: icon-group-errors@cs.arizona.edu
  14.  
  15.  
  16. I haven't seen too many handy doodads recently. I have a unix icon
  17. snippet of code. I guess I was too lazy to figure out the 'find' alias
  18. I'd need, so I pieced together ff (file finder). I wrote it for the
  19. Ultrix unix system. It requires the HOME environmental variable to
  20. search ones directory tree. Don't use it from the root account, and
  21. it only searches the directories beginning at HOME. If you have a
  22. different unix, or your terminal doesn't support ansi highlighting,
  23. you may have to modify some things. It doesn't do regular expressions,
  24. but it does find substrings. Enjoy.
  25.  
  26. Chris Tenaglia (System Manager) | Medical College of Wisconsin
  27. 8701 W. Watertown Plank Rd.     | Milwaukee, WI 53226
  28. (414)257-8765                   | tenaglia@mis.mcw.edu
  29.  
  30. #
  31. # FILE : FF.ICN
  32. # DESC : This program does a file find.
  33. #        It works only from your home account directory tree.
  34. #        Don't use if you're root or looking beyond your user account.
  35. #        Highlights substring with ansi sequences.
  36. # USE  : ff substr
  37. #
  38. # UPDATE         BY          WHAT
  39. # 22-APR-1994    TENAGLIA    INITIAL WRITE
  40. #
  41. procedure main(param)
  42.   home := getenv("HOME")
  43.   command := "ls -alR " || home
  44.   pipe := open(command,"pr")
  45.   part := param[1] | stop("Nothing to ff!")
  46.  
  47.   every drip := !pipe do
  48.     {
  49.     if match("/",drip) then 
  50.       {
  51.       home := drip[1:upto(":",drip)]
  52.       next
  53.       }
  54.     file := home || "/" || parse(drip,' ')[-1]      # construct full filename
  55.     if match( ("./" | ".."), file) then next        # skip this junk
  56.     if find(part,file) then                         # case sensitive matching
  57.       {
  58.       drip[46:0]  := ""
  59.       drip      ||:= file
  60.       drip[11:24] := ""
  61.       i           := find(part,drip) - 1            # *** warning ***
  62.       j           := i + *part                      # these lines put ansi
  63.       (drip[j]  ||:= "\e[m") | (drip ||:= "\e[m")   # highlighting around
  64.       drip[i]   ||:= "\e[1m"                        # the matched substring
  65.       write(drip)
  66.       }
  67.     }
  68.   close(pipe)
  69.   end
  70. #
  71. # parse a string into a list using a delimiter
  72. #
  73. procedure parse(line,delims)
  74.   static chars
  75.   chars  := &cset -- delims
  76.   tokens := []
  77.   line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  78.   return tokens
  79.   end
  80.  
  81.